import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'
import { IsDefined, IsInt, IsNotEmpty, IsString } from 'class-validator'
import { PageDto } from '../../common/dto/dto'

/*
 * @Author: fhw
 * @Date: 2022-07-28 16:13:15
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2022-08-05 11:12:35
 * @Description:
 */
export class DelteIdDto {
  @IsNotEmpty({ message: 'id不能为空' })
  @IsInt({ message: 'id不是整数' })
  @IsDefined()
  @ApiProperty({
    type: Number,
    name: 'id',
    description: 'id',
  })
  public readonly id: number
}
// 文章分类
export class ArticleCategoryDto extends PageDto {
  @ApiPropertyOptional({
    type: String,
    name: 'name',
    description: '名称',
  })
  public readonly name?: string
}
export class UpdateCategoryDto extends DelteIdDto {
  @IsDefined({ message: '名称不能为空' })
  @IsNotEmpty({ message: '名称不能为空' })
  @IsString({ message: '名称不是String类型' })
  @ApiProperty({
    type: String,
    name: 'name',
    description: '名称',
  })
  public readonly name?: string
}
export class CreateCategoryDto {
  @IsDefined({ message: '名称不能为空' })
  @IsNotEmpty({ message: '名称不能为空' })
  @IsString({ message: '名称不是String类型' })
  @ApiProperty({
    type: String,
    name: 'name',
    description: '名称',
  })
  public readonly name?: string
}
